<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改账单管理')" />
    <th:block th:include="include :: datetimepicker-css" />
    <th:block th:include="include :: select2-css" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
<!--        <input name="projects" id="projects" type="hidden" th:value="${projects}">-->
        <form class="form-horizontal m" id="form-bill-edit" th:object="${billInfo}">
            <input name="billId" th:field="*{billId}" type="hidden" required>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">序号：</label>
                <div class="col-sm-8">
                    <input name="serialNumber" th:field="*{serialNumber}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">项目名称：</label>
                <div class="col-sm-8">
                    <input name="projectName" th:field="*{projectName}" class="form-control" type="text" required>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">单位名称：</label>
                <div class="col-sm-8">
                    <input name="companyName" th:field="*{companyName}" class="form-control" type="text" required>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label is-required">收费类型：</label>
                <div class="col-sm-8">
                    <input name="chargeType" th:field="*{chargeType}" class="form-control" type="text" required>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">票据开始时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="billingTimeStart" th:value="${#dates.format(billInfo.billingTimeStart, 'yyyy-MM-dd')}"class="form-control" placeholder="请填写日期" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">票据结束时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="billingTimeEnd"  th:value="${#dates.format(billInfo.billingTimeEnd, 'yyyy-MM-dd')}"class="form-control" placeholder="请填写日期" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">开票时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="billingTime" th:value="${#dates.format(billInfo.billingTime, 'yyyy-MM-dd')}" class="form-control" placeholder="请填写日期" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">开票金额：</label>
                <div class="col-sm-8">
                    <input name="billCount" th:field="*{billCount}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">发票号：</label>
                <div class="col-sm-8">
                    <input name="billNumber" th:field="*{billNumber}" class="form-control" type="text">
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">到账金额：</label>
                <div class="col-sm-8">
                    <input name="receivedCount" th:field="*{receivedCount}" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">到账时间：</label>
                <div class="col-sm-8">
                    <div class="input-group date">
                        <input name="receivedTime"  th:value="${#dates.format(billInfo.receivedTime, 'yyyy-MM-dd')}" class="form-control" placeholder="请填写日期" type="text">
                        <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    </div>
                </div>
            </div>


            <div class="form-group">
                <label class="col-sm-3 control-label">到账状态：</label>
                <div class="col-sm-8">
                    <div class="radio-box " id="chooseStatus">
                        <label class="radio-box"> <input type="radio"  name="receivedStatus" value="0" /> 未到账 </label>
                        <label class="radio-box"> <input type="radio"  name="receivedStatus" value="1" /> 已到账 </label>
                    </div>
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">备注：</label>
                <div class="col-sm-8">
                    <textarea name="remark" th:field="*{remark}" class="form-control">[[*{remark}]]</textarea>
                </div>
            </div>
        </form>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <th:block th:include="include :: select2-js" />
    <script th:inline="javascript">
        var prefix = ctx + "guomao/billManagement";

        /*将后台的值传入前台*/
        var billInfo = [[${billInfo}]];

        /*$(document).ready(function(){initChoice();})的简写
        * function () {}里面的内容是在页面都加载完才执行*/
        $(function () {
            initStatusChoice();
        })


        /*到账状态回显*/
        function initStatusChoice(){
            var choice = billInfo.receivedStatus
            console.log("choice="+choice)
            $("#chooseStatus input").each(function () {
            if($(this).val()==choice){
                $(this).parent().addClass("checked")
                $(this).attr("checked",true)
            }
            });
        }



        $("#form-bill-edit").validate({
            focusCleanup: true
        });

// 			表单提交操作
        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-bill-edit').serialize());
            }
        }


        $("input[name='billingTimeStart']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='billingTimeEnd']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='billingTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

        $("input[name='receivedTime']").datetimepicker({
            format: "yyyy-mm-dd",
            minView: "month",
            autoclose: true
        });

    </script>
</body>
</html>